class Solution
{
public:
    int minNumber(vector<int> &nums1, vector<int> &nums2)
    {
        int result = 100;
        for (int num1 : nums1)
        {
            for (int num2 : nums2)
            {
                if (num1 == num2)
                {
                    result = min(result, num1);
                }
            }
        }
        if (result < 100)
        {
            return result;
        }
        int min1 = *min_element(nums1.begin(), nums1.end());
        int min2 = *min_element(nums2.begin(), nums2.end());
        result = min(min1 * 10 + min2, min2 * 10 + min1);
        return result;
    }
};